<template>
	<view class="">
		<u-datetime-picker :show="show" v-model="value1" mode="datetime" @confirm="confirm" cancelColor="#1BA95B"
			confirmColor="#1BA95B" @cancel="cancel"></u-datetime-picker>
		<view class="" style="padding-bottom: 120rpx;">
			<view class="mainpadding ffffff">
				<view class="ershiba nofonweight xiaohei">赛事主图</view>
				<view class="margin_top shangc" v-if="!image" @click="uploadImg(1)">
					<image src="../static/image/system/shangchuan.png" mode=""></image>
				</view>
				<view class="margin_top shangc" v-if="image" @click="uploadImg(1)">
					<image :src="image_text" mode=""></image>
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">赛事轮播图（{{images_text.length}}/5）</view>
				<view class="flexleft flex_wrap">
					<view class="shilitu margin_top margin_right2 dingwei" v-for="(item,index) in images_text"
						:key="index">
						<image :src="item" mode=""></image>
						<view class="shanchu" @click="delindex(index,images_text,images)">
							<u-icon name="close-circle-fill"></u-icon>
						</view>
					</view>
					<view class="margin_top shangc margin_right2" v-if="images.length<5"
						@click="uploadImg(5,images,images_text)">
						<image src="../static/image/system/shangchuan.png" mode=""></image>
					</view>
				</view>
				<view class="margin_top titletext bold hei_text">赛事公告视频</view>
				<view class="upzhizhao margin_top flexcenter" v-if="!ssgg_video" @click="upvideo(1)">
					<u-icon name="plus" color="#999" size="28"></u-icon>
				</view>
				<view v-if="ssgg_video" class="upzhizhao margin_top" style="position: relative;">
					<video :src="ssgg_video_text" object-fit="cover" class="upzhizhao"></video>
					<view class="shanchu" @click="delvideo(1)">
						<u-icon name="close-circle-fill"></u-icon>
					</view>
				</view>
				<view class="margin_top titletext bold hei_text">赛事赞助单位视频</view>
				<view class="upzhizhao margin_top flexcenter" v-if="!sszzdw_video" @click="upvideo(2)">
					<u-icon name="plus" color="#999" size="28"></u-icon>
				</view>
				<view v-if="sszzdw_video" class="upzhizhao margin_top" style="position: relative;">
					<video :src="sszzdw_video_text" object-fit="cover" class="upzhizhao"></video>
					<view class="shanchu" @click="delvideo(2)">
						<u-icon name="close-circle-fill"></u-icon>
					</view>
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">赛事名称</view>
				<view class="margin_top">
					<u--input placeholder="请输入赛事名称" border="surround" v-model="name"></u--input>
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">赛事公告图片（{{ssgg_images_text.length}}/5）</view>
				<view class="flexleft flex_wrap">
					<view class="shilitu margin_top margin_right2 dingwei" v-for="(item,index) in ssgg_images_text"
						:key="index">
						<image :src="item" mode=""></image>
						<view class="shanchu" @click="delindex(index,ssgg_images_text,ssgg_images)">
							<u-icon name="close-circle-fill"></u-icon>
						</view>
					</view>
					<view class="margin_top shangc margin_right2" v-if="ssgg_images.length<5"
						@click="uploadImg(5,ssgg_images,ssgg_images_text)">
						<image src="../static/image/system/shangchuan.png" mode=""></image>
					</view>
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">赛事赞助单位图片（{{sszzdw_images.length}}/5）</view>
				<view class="flexleft flex_wrap">
					<view class="shilitu margin_top margin_right2 dingwei" v-for="(item,index) in sszzdw_images"
						:key="index">
						<image :src="item" mode=""></image>
						<view class="shanchu" @click="delindex(index,sszzdw_images_text,sszzdw_images)">
							<u-icon name="close-circle-fill"></u-icon>
						</view>
					</view>
					<view class="margin_top shangc margin_right2" v-if="sszzdw_images.length<5"
						@click="uploadImg(5,sszzdw_images_text,sszzdw_images)">
						<image src="../static/image/system/shangchuan.png" mode=""></image>
					</view>
				</view>
			</view>
			<view class="mainpadding ffffff margin_top1">
				<!-- <view class="xiahuaxian flexbetween">
					<view class="ershiba nofonweight xiaohei">组织人头像</view>
					<view class="touxiang">
						<image src="../static/image/system/ms.png" mode=""></image>
					</view>
				</view> -->
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">组织人姓名</view>
					<input class="textright" type="text" placeholder="输入姓名" v-model="zbfzzr">
				</view>
				<!-- <view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">组织人手机号</view>
					<input class="textright" type="text" placeholder="输入组织人手机号" v-model="zbfmobile">
				</view> -->
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">报名开始时间</view>
					<view class="flexright" @click="messageTime.timeShow = true;timevalue=1">
						<input class="textright" type="text" placeholder="请选择" disabled v-model="bm_starttime">
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">报名结束时间</view>
					<view class="flexright" @click="messageTime.timeShow = true;timevalue=2">
						<input class="textright" type="text" placeholder="请选择" disabled v-model="bm_endtime">
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">赛事开始时间</view>
					<view class="flexright" @click="messageTime.timeShow = true;timevalue=3">
						<input class="textright" type="text" placeholder="请选择" disabled v-model="bs_starttime">
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">赛事结束时间</view>
					<view class="flexright" @click="messageTime.timeShow = true;timevalue=4">
						<input class="textright" type="text" placeholder="请选择" disabled="" v-model="bs_endtime">
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>

				<uni-data-picker @change="bindPickerChange" :localdata="items" placeholder="请选择住址" popup-title="请选择地区"
					v-model="area_id" class="zdy">
					<view class="xiahuaxian margin_top flexbetween">
						<view class="ershiba xiaohei nofonweight">城市</view>
						<view class="flexright">
							<input type="text" class="textright" placeholder="请选择" v-model="city_text" disabled=""
								style="width: 80%;">
							<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
				</uni-data-picker>
				<view class="xiahuaxian flexbetween margin_top" @click="chooselocation">
					<view class="ershiba nofonweight xiaohei">赛事地址</view>
					<view class="flexright">
						<input type="text" class="textright" placeholder="请选择" v-model="address" disabled=""
							style="width: 80%;">
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">赛事类型</view>
					<view class="flexright">
						<u-radio-group v-model="type" placement="row" circle>
							<u-radio activeColor="#1ba95b" :customStyle="{marginRight: '30rpx'}" label="个人赛"
								name="1"></u-radio>
							<u-radio activeColor="#1ba95b" label="团体赛" name="2"></u-radio>
						</u-radio-group>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top" @click="bqshow = true">
					<view class="ershiba nofonweight xiaohei">赛事标签</view>
					<view class="flexright">
						<input class="textright" type="text" v-model="selectbqtext" placeholder="请选择" disabled="">
						<u-icon name="arrow-right"></u-icon>

					</view>
				</view>
				<view class="xiahuaxian">
					<view class=" flexbetween margin_top">
						<view class="ershiba nofonweight xiaohei">标签</view>
						<view class="flexright">
							<input class="textright margin_right2" type="text" placeholder="请输入后添加" v-model="bqtext"
								@confirm="addsheshi">
							<u-icon name="plus-square-fill" color="#1BA95B" size="28"
								@click="addsheshi"></u-icon>
						</view>
					</view>
					<view class="flexleft flex_wrap">
						<view class="lvbtn margin_top1 margin_right1 flexleft" v-for="(item,index) in bqarr"
							:key="index">
							<text class="margin_right1">{{item}}</text>
							<u-icon name="close-circle" color="#999" size="16" @click="bqarr.splice(index,1)"></u-icon>
						</view>
					</view>
				</view>

				<view class="xiahuaxian flexbetween margin_top" @click="xmShow = true">
					<view class="ershiba nofonweight xiaohei">项目</view>
					<view class="flexright">
						<input class="textright" type="text" placeholder="请选择" disabled="" v-model="cg_category_name">
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">{{type==1?"个人":"团队"}}赛事费用</view>
					<view class="flexright">
						<input class="textright" type="text" placeholder="输入赛事费用" v-model="price">
						<view class="ershiba nofonweight xiaohei">元</view>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">参加{{type==1?'人数':'团队数'}}</view>
					<input class="textright" type="number" placeholder="输入报名团队数" v-model="join_num">
				</view>
				<view class="xiahuaxian flexbetween margin_top" v-if="type==2">
					<view class="ershiba nofonweight xiaohei">参加团队人数</view>
					<input class="textright" type="number" placeholder="输入报名人数" v-model="team_num">
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">男性人数</view>
					<input class="textright" type="number" placeholder="输入男性人数" v-model="man_num">
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">女性人数</view>
					<input class="textright" type="number" placeholder="输入女性人数" v-model="womam_num">
				</view>
				<view class="xiahuaxian flexbetween margin_top" v-if="type==1">
					<view class="ershiba nofonweight xiaohei">性别</view>
					<view class="flexright">
						<u-radio-group v-model="xb_type" placement="row" circle>
							<u-radio activeColor="#1ba95b" :customStyle="{marginRight: '30rpx'}" label="不限"
								name="0"></u-radio>
							<u-radio activeColor="#1ba95b" label="男" :customStyle="{marginRight: '30rpx'}"
								name="1"></u-radio>
							<u-radio activeColor="#1ba95b" label="女" name="2"></u-radio>
						</u-radio-group>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top" v-if="listid">
					<view class="ershiba nofonweight xiaohei">是否上架</view>
					<view class="flexright">
						<u-radio-group v-model="status" placement="row" circle>
							<u-radio activeColor="#1ba95b" :customStyle="{marginRight: '30rpx'}" label="上架"
								name="normal"></u-radio>
							<u-radio activeColor="#1ba95b" label="下架" name="hidden"></u-radio>
						</u-radio-group>
					</view>
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">赛事公告描述</view>
				<view class="margin_top">
					<u--textarea v-model="ssgg_des" placeholder="请输入赛事公告描述" count></u--textarea>
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">赛事赞助单位描述</view>
				<view class="margin_top">
					<u--textarea v-model="sszzdw_des" placeholder="请输入赛事赞助单位描述" count></u--textarea>
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">赛事说明</view>
				<view class="margin_top">
					<u--textarea v-model="sssm" placeholder="请输入赛事说明" count></u--textarea>
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">赛事章程</view>
				<view class="margin_top">
					<u--textarea v-model="sszc" placeholder="请输入赛事章程" count></u--textarea>
				</view>
			</view>
		</view>

		<view class="gudingdb ffffff mainpadding">
			<view class="bigbtn" @click="submit">保存</view>
		</view>
		<timePicker :messageTime="messageTime" @timeConfirm="timeConfirm"></timePicker>
		<u-picker :show="xmShow" :columns="xmList" title="选择类型" @cancel="xmShow=false" @confirm="xmconfirm"
			keyName="name"></u-picker>
		<u-popup :show="bqshow" @close="bqshow=false">
			<view class="mainpadding ">
				<view class="mainpadding textcenter titletext fonweight">赛事标签</view>
				<view class="flexleft flex_wrap margin_top">
					<!-- 未选中 -->
					<view :class="item.ischeck?'lvbtn margin_right1 margin_top1':'huibtn margin_right1 margin_top1'"
						v-for="item in ssbqList" :key="item.id" @click="checkssbq(item)">{{item.name}}</view>
				</view>
			</view>

		</u-popup>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	import citys from "@/static/city/city.js"
	export default {
		data() {
			return {
				value: '',
				value2: '',
				show: false,
				value1: Number(new Date()),
				image: "",
				image_text: "",
				images: [],
				images_text: [],
				sszzdw_video: "",
				sszzdw_video_text: "",
				sssm: "",
				sszc: "",
				sszzdw_des: "",
				name: "",
				zbfzzr: "",
				// zbfmobile: "18574139993",
				bm_starttime: "",
				bm_endtime: "",
				bs_starttime: "",
				bs_endtime: "",
				ssgg_video: "",
				ssgg_video_text: "",
				ssgg_images: [],
				ssgg_images_text: [],
				sszzdw_images: [],
				sszzdw_images_text: [],
				ssgg_des: "",
				type: "1", //类型:1=个人赛事2=团体赛事
				// address: "西四环悦润府西区1-2-2021",
				address: "",
				province_id: "",
				city_id: "",
				area_id: "",
				latitude: "",
				longitude: "",
				price: "",
				join_num: "",
				team_num: "",
				man_num: "",
				womam_num: "",
				xb_type: "0", //性别类型:0=不限制,1=男性,2=女性
				cg_category_id: "", //项目
				cg_category_name: "",
				items: citys.data,
				city_text: "",
				upvalue: 0,
				messageTime: {
					timeShow: false,
					title: "选择时间",
					mode: "datetime" //date日期，datetime年月日时分秒，time时间
				},
				timevalue: 0, //1报名开始,2报名结束,3赛事开始,4赛事结束
				xmShow: false,
				xmList: [],
				status: "normal", //状态:normal=启用,hidden=隐藏
				listid: "",
				checkvideo: 0,
				bqshow: false,
				// 赛事标签
				ssbqList: [],
				bqtext: "",
				bqarr: [],
				ss_bq_ids: [],
				selectbqtext: "",
				user_zbfapply_listid:""

			}
		},
		onLoad(options) {
			this.user_zbfapply_listid=options.user_zbfapply_listid
			if (options.id) {
				uni.setNavigationBarTitle({
					title: "编辑赛事"
				})
				this.listid = options.id
				this.getDetail()
				this.getcgfl() //场馆分类/项目
			} else {
				this.getcgfl() //场馆分类/项目
				this.getssbq() //赛事标签
			}
		},
		methods: {
			addsheshi(){
				if(this.bqtext==""){
					httpRequest.toast("请输入后添加")
					return false
					
				}
				this.bqarr.push(this.bqtext);
				this.bqtext=''
			},
			ssbqListfn() {
				let arr = []
				this.ssbqList.forEach(item => {
					if (item.ischeck) {
						arr.push(item.name)
					}
				})
				this.selectbqtext = arr.length ? arr.join() : ""
			},
			getssbq(val) {
				httpRequest.request('/api/sscl/ssBqIndex', 'POST', {}, false, false, true).then(res => {
					res.data.forEach(item => {
						this.$set(item, "ischeck", false)
						this.ss_bq_ids.forEach(ite => {
							if (ite == item.id) {
								item.ischeck = true
							}
						})
					})
					this.ssbqList = res.data
					this.ssbqListfn()
				})
			},
			getDetail() {
				httpRequest.request('/api/sscl/mySsDetail', 'GET', {
					id: this.listid,
					user_zbfapply_id:this.user_zbfapply_listid
				}).then(res => {
					let data = res.data
					this.image = data.image
					this.image_text = data.image_text
					this.images = data.images.split(",")
					this.images_text = data.images_text
					this.ssgg_images = data.ssgg_images.split(",")
					this.ssgg_images_text = data.ssgg_images_text
					this.sszzdw_video = data.sszzdw_video
					this.sszzdw_video_text = data.sszzdw_video_text
					this.sszzdw_images = data.sszzdw_images.split(",")
					this.sszzdw_images_text = data.sszzdw_images_text
					this.sszzdw_des = data.sszzdw_des
					this.sssm = data.sssm
					this.sszc = data.sszc
					this.name = data.name
					this.bqarr = data.bq_names_text
					this.zbfzzr = data.zbfzzr
					// this.zbfmobile = data.zbfmobile
					this.bm_starttime = data.bm_starttime_text
					this.bm_endtime = data.bm_endtime_text
					this.bs_starttime = data.bs_starttime_text
					this.bs_endtime = data.bs_endtime_text
					this.ssgg_video = data.ssgg_video
					this.ssgg_video_text = data.ssgg_video_text
					this.ssgg_des = data.ssgg_des
					this.type = data.type.toString()
					this.address = data.address
					this.longitude = data.longitude
					this.latitude = data.latitude
					this.price = data.price
					this.join_num = data.join_num
					this.team_num = data.team_num
					this.man_num = data.man_num || ""
					this.xb_type = data.xb_type.toString()
					this.cg_category_id = data.cg_category_id
					this.cg_category_name = data.cgcategory.name
					this.womam_num = data.womam_num || ""
					this.status = data.status
					this.city_text = data.cityinfo
					this.province_id = data.province_id
					this.city_id = data.city_id
					this.area_id = data.area_id
					this.address = data.address
					this.ss_bq_ids = data.ss_bq_ids.split(',')
					this.getssbq() //赛事标签
				})
			},
			submit() {
				if (this.image == "") {
					httpRequest.toast("请上传赛事主图")
					return false
				}
				if (!this.images.length) {
					httpRequest.toast("请上传赛事轮播图")
					return false
				}
				if (this.name == "") {
					httpRequest.toast("请输入赛事名称")
					return false
				}
				if (!this.ssgg_images.length) {
					httpRequest.toast("请上传赛事公告图片")
					return false
				}
				if (!this.sszzdw_images.length) {
					httpRequest.toast("请上传赛事公告图片")
					return false
				}
				if (this.zbfzzr == "") {
					httpRequest.toast("请输入组织人姓名")
					return false
				}
				// if (this.zbfmobile == "") {
				// 	httpRequest.toast("请输入组织人手机号")
				// 	return false
				// }
				if (this.bm_starttime == "") {
					httpRequest.toast("请选择报名开始时间")
					return false
				}
				if (this.bm_starttime == "") {
					httpRequest.toast("请选择报名结束时间")
					return false
				}
				if (this.bs_starttime == "") {
					httpRequest.toast("请选择比赛开始时间")
					return false
				}
				if (this.bs_endtime == "") {
					httpRequest.toast("请选择比赛结束时间")
					return false
				}
				if (this.area_id == "") {
					httpRequest.toast("请选择城市")
					return false
				}
				if (this.address == "") {
					httpRequest.toast("请选择赛事地址")
					return false
				}
				let arr = []
				this.ssbqList.forEach(item => {
					if (item.ischeck) {
						arr.push(item.id)
					}
				})
				if (!arr.length) {
					httpRequest.toast("请至少选择一个赛事标签")
					return false
				}
				if (this.cg_category_id == "") {
					httpRequest.toast("请选择项目")
					return false
				}
				if (this.price == "") {
					httpRequest.toast("请输入赛事费用")
					return false
				}

				if (this.join_num == "") {
					httpRequest.toast("请输入参加人数")
					return false
				}
				if (this.type == 2) {
					if (this.team_num == "") {
						httpRequest.toast("请输入参加团队人数")
						return false
					}
					if(this.womam_num || this.man_num){
						if(this.womam_num!=this.team_num && this.man_num!=this.team_num){
							if (!this.man_num) {
								httpRequest.toast("请输入参加男性人数")
								return false
							}
							if (!this.womam_num) {
								httpRequest.toast("请输入参加女性人数")
								return false
							}
						}
						if(Number(this.womam_num)+Number(this.man_num) != Number(this.team_num)){
							httpRequest.toast("参加男性和女性人数总和要等于参加人数")
							return false
						}
					}
					
				}

				if (this.ssgg_des == "") {
					httpRequest.toast("请输入赛事公告描述")
					return false
				}
				if (this.sszzdw_des == "") {
					httpRequest.toast("请输入赛事赞助单位描述")
					return false
				}
				if (this.sssm == "") {
					httpRequest.toast("请输入赛事说明")
					return false
				}
				if (this.sszc == "") {
					httpRequest.toast("请输入赛事章程")
					return false
				}
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				let url = "/api/sscl/addSs"
				let data = {
					image: this.image,
					images: this.images.join(),
					ssgg_images: this.ssgg_images.join(),
					name: this.name,
					zbfzzr: this.zbfzzr,
					bm_starttime: this.bm_starttime,
					bm_endtime: this.bm_endtime,
					bs_starttime: this.bs_starttime,
					bs_endtime: this.bs_endtime,
					ssgg_video: this.ssgg_video,
					ssgg_des: this.ssgg_des,
					sszzdw_video: this.sszzdw_video,
					sszzdw_images: this.sszzdw_images.join(),
					sszzdw_des: this.sszzdw_des,
					sssm: this.sssm,
					sszc: this.sszc,
					type: this.type,
					address: this.address,
					longitude: this.longitude,
					latitude: this.latitude,
					price: this.price,
					join_num: this.join_num,
					team_num: this.team_num,
					man_num: this.man_num,
					xb_type: this.xb_type,
					ss_bq_ids: arr.join(),
					bq_names: this.bqarr.join(),
					cg_category_id: this.cg_category_id,
					womam_num: this.womam_num,
					province_id: this.province_id,
					city_id: this.city_id,
					area_id: this.area_id,
					user_zbfapply_id:this.user_zbfapply_listid
				}
				if (this.listid) {
					url = "/api/sscl/editSs"
					this.$set(data, "id", this.listid)
					this.$set(data, "status", this.status)
				}
				httpRequest.request(url, 'POST', data).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
				})
			},
			chooselocation() {
				let _this = this
				uni.chooseLocation({
					success: function(response) {
						_this.address = response.address
						_this.latitude = response.latitude
						_this.longitude = response.longitude
					},
					fail(res) {
						console.log(res, "失败了");
					}
				})
			},
			checkssbq(item) {
				item.ischeck = !item.ischeck
				this.ssbqListfn()
			},
			xmconfirm(e) {
				this.cg_category_id = e.value[0].id
				this.cg_category_name = e.value[0].name
				this.xmShow = false
			},
			getcgfl() {
				httpRequest.request('/api/index/cgCategory', 'POST', {}, false, false, true).then(res => {
					this.xmList.push(res.data)
				})
			},
			timeConfirm(e) {
				if (this.timevalue == 1) this.bm_starttime = e
				if (this.timevalue == 2) this.bm_endtime = e
				if (this.timevalue == 3) this.bs_starttime = e
				if (this.timevalue == 4) this.bs_endtime = e
				this.messageTime.timeShow = false
			},
			// 跳转完成创建
			tzwccj() {
				uni.navigateTo({
					url: '/pages_julebu/chuangjianwc'
				})
			},
			bindPickerChange(val) {
				let area = val.detail.value
				let area_text = [area[0].text, area[1].text, area[2].text];
				this.city_text = area_text.join("/")
				this.province_id = area[0].value;
				this.city_id = area[1].value;
				this.area_id = area[2].value;
			},
			confirm(e) {
				console.log(e)
				this.show = false
			},
			cancel() {
				this.show = false
			},
			uploadImg(value, upImgs, upImgs_text) { //上传图片
				let _this = this;
				this.upvalue = value
				let num = 0
				if (value == 5) {
					num = Number(value) - upImgs.length;
					if (num <= 0) {
						return false;
					}
				} else {
					num = 1
				}
				uni.showActionSheet({
					itemList: ['相机', '相册'],
					success: function(res) {
						// 选择相机走0
						if (res.tapIndex == 0) {
							httpRequest.chooseImage(num, ['camera']).then(res => {
								for (var i = 0; i < res.length; i++) {
									_this.uploadImageService(res[i], upImgs, upImgs_text)
								}
							}).catch(err => {});
						}
						// 选择相册走1
						if (res.tapIndex == 1) {
							httpRequest.chooseImage(num, ['album']).then(res => {
								for (var i = 0; i < res.length; i++) {
									_this.uploadImageService(res[i], upImgs, upImgs_text)
								}
							}).catch(err => {});
						}
					},
					fail: function(res) {}
				});
			},
			delindex(index, upImg, upImgs_text) {
				upImg.splice(index, 1)
				upImgs_text.splice(index, 1)
			},
			uploadImageService(url, upImg, upImgs_text) {
				let _this = this;
				httpRequest.uploadFile('/api/common/upload', url).then(res => {
					let image_item = res.fullurl;
					if (this.upvalue == 1) {
						this.image = res.url
						this.image_text = image_item
						return false
					}
					upImg.push(res.url)
					upImgs_text.push(image_item);
				}).catch(err => {});
			},
			upvideo(val) { //上传视频
				let uploadFile = ''
				this.checkvideo = val
				let _this = this;
				// 1.选择要上传的视频
				uni.chooseVideo({
					maxDuration: 60, // 拍摄视频最长拍摄时间，单位秒。最长支持 60 秒。
					sourceType: ['album', 'camera'], // album 从相册选视频，camera 使用相机拍摄，默认为：['album', 'camera']
					success: function(res) {
						_this.uploadImageServicet(res.tempFilePath)
					}
				});
			},
			uploadImageServicet(url, upImg, upImgs_text) {
				let _this = this;
				httpRequest.uploadFile('/api/common/upload', url).then(res => {
					let image_item = res.fullurl;
					if (this.checkvideo == 1) {
						this.ssgg_video = res.url
						this.ssgg_video_text = image_item
					} else if (this.checkvideo == 2) {
						this.sszzdw_video = res.url
						this.sszzdw_video_text = image_item
					}

				}).catch(err => {});
			},
			delvideo(val) {
				if (val == 1) {
					this.ssgg_video = ""
					this.ssgg_video_text = ""
				} else if (val == 2) {
					this.sszzdw_video = ""
					this.sszzdw_video_text = ""
				}

			},
		}
	}
</script>

<style lang="scss" scoped>
	.huibtn {
		background: #F9F9F9;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		padding: 15rpx 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #777777;
	}

	.lvbtn {
		background: #DFFFED;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		padding: 15rpx 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #1BA95B;
	}

	.touxiang {
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;

		image {
			border-radius: 50%;
			width: 100%;
			height: 100%;
		}
	}

	.dizneo {
		height: 500rpx;
		overflow: auto;
	}

	.xiaolbtn {
		width: 112rpx;
		height: 48rpx;
		background: rgba(27, 169, 91, 0.1);
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #1BA95B;
		border: 2rpx solid #1BA95B;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	page {

		background: #F9F9F9;
	}

	.shanchu {
		position: absolute;
		top: -10rpx;
		right: -10rpx;
	}

	.shanchu2 {
		position: absolute;
		bottom: -10rpx;
		right: -50%;
		transform: translate(0, -50%);
	}

	.shilitu {
		width: 160rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.shangc {
		width: 160rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>